Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
Window.close not working for rel="noreferrer" but works with rel="opener"

Recently, at work, i made a redirection to another site. The maintainers of the other site contacted me and told me that their window.close are not working anymore. Here is a simple explanation of the problem:

let's say site A has an <a href="http://siteB" target="_blank" rel="noreferrer"> tag to navigate to the home page of site B. In the home page of site B, when you use window.close(), the window is closed. Now,(still in the site B), when the user navigates to another page (let's say /about page), a window.close in this page will not work. Chrome shows this warning:

Scripts may close only the windows that were opened by it.

But in the <a> tag, when i replaced rel="noreferrer" by rel="opener", window.close works in any page of the site B. For rel="noreferrer", window.close only works in the first page of the redirection. If i understand well the warning message, it's because the /about page was not opened by the site A, that's why window.close will not work in that page. But my question is, why by just changing rel="noreferrer" to rel="opener", window.close now works everywhere in site B?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In documentation of rel in mozilla there's saying rel="noopener" or rel="noreferrer"

Creates a top-level browsing context that is not an auxiliary browsing context.

The window opened like that has a top-level context.

But for rel="opener"

Creates an auxiliary browsing context.

It means it's not a top-level.

And now for documentation of window.close() there is

This method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

So for closing window by close() function the window shouldn't has top-level context.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda